getUsermsg();
function getUsermsg(e) {
  $.ajax({
    type: "get",
    url: "/my/userinfo",
    success: function (res) {
      if (res.status != 0) return layui.layer.msg(res.message);

      xuanRan(res.data);
    },
    // complete: function (res) {
    //   // console.log(res);
    //   if (
    //     res.responseJSON.status === 1 && 
    //     res.responseJSON.message === "身份认证失败!"
    //   ) {
    //     location.href = "/login.html"
    //     localStorage.removeItem('token')
    //   }
    //   // }
    // },
  });
}

function xuanRan(data) {
  var name = data.nickname || data.username;
  $("#welcome").html("欢迎" + name);
  if (data.user_pic != null) {
    $(".layui-nav-img").attr("src", data.user_pic).show();
    $(".text-avatar").hide();
  } else {
    $(".layui-nav-img").hide();
    var oneName = data.username[0];
    $(".text-avatar").html(oneName);
  }
}

$("#nav-tui").click(function (e) {
  e.preventDefault();
  layer.confirm("is not?", { icon: 3, title: "提示" }, function (index) {
    //do something

    location.href = "login.html";
    localStorage.removeItem("token");

    layer.close(index);
  });
});
